package com.jwds.digital.bios.business.core.infrastructure.dto.belt.assembler;

import com.jwds.digital.bios.business.core.infrastructure.dto.belt.BeltHealthConfigReqDTO;
import com.jwds.digital.bios.business.core.infrastructure.vo.belt.BeltHealthConfigRespVO;
import com.jwds.digital.bios.business.core.infrastructure.entity.belt.BeltHealthConfig;
import java.util.Objects;


/**
 * BeltHealthConfig DTO与Entity之间的相互转换
 *
 * @author 林柏云
 * @date 2024-10-24
 */
public class BeltHealthConfigAssembler {

  /**
  * 将传输对象转换为实体对象
  *
  * @param dto 传输对象
  * @return 实体对象
  */
  public static BeltHealthConfig dto2entity(BeltHealthConfigReqDTO dto)  {
    if (dto == null) {
      return null;
    }
    BeltHealthConfig entity = new BeltHealthConfig();
    entity.setDeductionItem(dto.getDeductionItem());
    entity.setDeductionRangeMax(dto.getDeductionRangeMax());
    entity.setDeductionRangeMin(dto.getDeductionRangeMin());
    entity.setUnit(dto.getUnit());
    entity.setDeductionScore(dto.getDeductionScore());
    entity.setDeductionSuggestion(dto.getDeductionSuggestion());
    entity.setConfigType(dto.getConfigType());
    entity.setHealthType(dto.getHealthType());
    entity.setIsDeleted(0);
    return entity;
  }

  /**
  * 将传输对象转换为实体对象
  *
  * @param dto 传输对象
  * @param entity 原实体对象
  * @return 实体对象
  */
  public static BeltHealthConfig dto2entity(BeltHealthConfigReqDTO dto, BeltHealthConfig entity){
    if (dto == null) {
      return null;
    }
    if(Objects.nonNull(dto.getDeductionItem())) {
      entity.setDeductionItem(dto.getDeductionItem());
    }
    if(Objects.nonNull(dto.getDeductionRangeMax())) {
      entity.setDeductionRangeMax(dto.getDeductionRangeMax());
    }
    if(Objects.nonNull(dto.getDeductionRangeMin())) {
      entity.setDeductionRangeMin(dto.getDeductionRangeMin());
    }
    if(Objects.nonNull(dto.getUnit())) {
      entity.setUnit(dto.getUnit());
    }
    if(Objects.nonNull(dto.getDeductionScore())) {
      entity.setDeductionScore(dto.getDeductionScore());
    }
    if(Objects.nonNull(dto.getDeductionSuggestion())) {
      entity.setDeductionSuggestion(dto.getDeductionSuggestion());
    }
    if(Objects.nonNull(dto.getConfigType())) {
      entity.setConfigType(dto.getConfigType());
    }
    if(Objects.nonNull(dto.getHealthType())) {
      entity.setHealthType(dto.getHealthType());
    }
    return entity;
  }

  /**
  * 将实体对象转换为传输对象
  *
  * @param entity 实体对象
  * @return 传输对象
  */
  public static BeltHealthConfigRespVO entity2dto(BeltHealthConfig entity) {
    if (entity == null) {
      return null;
    }
    BeltHealthConfigRespVO dto = new BeltHealthConfigRespVO();
    dto.setId(entity.getId());
    dto.setDeductionItem(entity.getDeductionItem());
    dto.setDeductionRangeMax(entity.getDeductionRangeMax());
    dto.setDeductionRangeMin(entity.getDeductionRangeMin());
    dto.setUnit(entity.getUnit());
    dto.setDeductionScore(entity.getDeductionScore());
    dto.setDeductionSuggestion(entity.getDeductionSuggestion());
    dto.setConfigType(entity.getConfigType());
    dto.setHealthType(entity.getHealthType());
    return dto;
  }

}
